/*
 * @Author: HotSuitor
 * @Date: 2020-03-12 12:48:48
 * @LastEditors: hs
 * @LastEditTime: 2020-03-12 12:52:09
 * @Description: hotsuitor@qq.com
 */
package main

import (
	"fmt"
)

func main() {
	// var countryCapitalMap map[string]string /*创建集合 */
	// fmt.Println(countryCapitalMap)
	countryCapitalMap := make(map[string]string)
	fmt.Println(countryCapitalMap)


	/* map插入key - value对,各个国家对应的首都 */
	countryCapitalMap [ "France" ] = "巴黎"
	countryCapitalMap [ "Italy" ] = "罗马"
	countryCapitalMap [ "Japan" ] = "东京"
	countryCapitalMap [ "India " ] = "新德里"

	/*使用键输出地图值 */
	for country := range countryCapitalMap {
			fmt.Println(country, "首都是", countryCapitalMap [country])
	}

	/*查看元素在集合中是否存在 */
	capital, ok := countryCapitalMap [ "American" ] /*如果确定是真实的,则存在,否则不存在 */
	/*fmt.Println(capital) */
	/*fmt.Println(ok) */
	if (ok) {
			fmt.Println("American 的首都是", capital)
	} else {
			fmt.Println("American 的首都不存在")
	}
}
